<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	import="java.util.List,DomainData.*,Application.Dao.*,Reservation.*"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="css/general.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script>


<script type="text/javascript">
    $(function() {
        $('.list_review_content').hover(
        function () {
            $(this).addClass("highlight");
          },
          function () {
            $(this).removeClass("highlight");
          });
    });

</script>
<script type="text/javascript">
	var req;
	function deleteReview(id) {
		if(confirm('Do you really want to delete the selected review?'))
		{	
			var url2 = "DeleteReview.jsp?id=" +escape(id);
			//alert(url2);
			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			req.open("GET", url2, true);
			req.onreadystatechange = callback;
			req.send(null);
		}
		
	}

	function callback() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				window.location.href=window.location.href;
				//var msg = req.responseXML.getElementsByTagName("msg")[0];
				//alert(msg);
				//setMsg(msg.childNodes[0].nodeValue);
			}
		}
	}
</script>
</head>

<body>
	<div class="mainBackground"></div>
	<div id="maincontent" class="center">
		<h2>Customer Reviews</h2>
		<p>&nbsp;</p>	

		<table id="list_review"  class="center">
			<tr bgcolor="#F2F2F2">
				<td>Review ID</td>
				<td>Customer Name</td>
				<td>Content</td>
				<td>Action</td>
			</tr>
			<%
			List<ReviewBean> reviews=ReviewDao.getReviewList();
			for (int i = 0; i < reviews.size(); i++) {
				ReviewBean r = reviews.get(i);
				int customerID=r.getUserID();
				UserBean customer=UserDAO.loadByID(customerID);
				String customerName=customer.getFirstName()+" "+customer.getLastName();
				out.println("<tr class='list_review_content'><td>"+ r.getReviewID()
						+ "</td><td>"+customerName+"</td><td>"+r.getContent()
						+"</td><td><a onclick=deleteReview("+"'"
								+ r.getReviewID()+"'"+") >Delete</a></td></tr>");
			}
			%>
			<tr></tr>
			
		</table>	
			<p>&nbsp;</p>	
			<p>&nbsp;</p>	
			<p>&nbsp;</p>	
	</div>
	<div class="clear"></div>
	
	<div id="footer">
		&copy; K&G Restaurant | all Rights Reserved by CSE 333 <span
			class="credit"><a
			href="http://www.weibo.com/gaotaojie/profile?topnav=1&wvr=4">Taojie
				Gao's Paradise</a> by Taojie Gao</span>

	</div>
</body>
</html>